<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class seo_model extends CI_Model {
	//모델 생성자 호출
	function __construct(){
		parent::__construct();
	
	}
	
	/**
	 * seo 설정 조회
	 *
	 * @access	public
	 * @return	array
	 */
	function select_seo(){
		$query = $this->db->get('ch_config_seo',1);
		if($query->num_rows() > 0){
			$row = $query->row_array();
			$data['dbjob'] = 'u';
			$data['seo_id'] = $row['seo_id'];
			$data['title'] = $row['title'];
			$data['keyword'] = $row['keyword'];
			$data['description'] = $row['description'];
			$data['script'] = $row['script'];
		}else{
			$data['dbjob'] = 'i';
			$data['seo_id'] = null;
			$data['title'] = null;
			$data['keyword'] = null;
			$data['description'] = null;
			$data['script'] = null;
		}
	  	return $data;
	}
	
	/**
	 * seo DB 처리
	 *
	 * @access	public
	 * @return	boolean
	 */
	function seo_dbjob($data){
		$dbjob = $this->input->post('dbjob');
		$id = $this->input->post('id');
		switch($dbjob){
			case('i'):	
				$int_result = $this->db->insert('ch_config_seo', $data);
			break;
			case('u'):
				$this->db->where('seo_id',$id);
				$int_result = $this->db->update('ch_config_seo',$data);
			break;
			case('d'):
				$int_result = $this->db->delete('ch_config_seo',$data);
			break;
		}
		return ($int_result > 0) ? true : false;
	}
	
}
?>